local blaze = require "blaze"
local log = blaze.logging.get("gamelib")
local gamelib = blaze.app.new({
    modules = {
        coroutine = "club.threecard.gamelib.coroutine",
        event = "club.threecard.gamelib.event",
        game = "club.threecard.gamelib.game",
        kbe = "club.threecard.gamelib.kbe",
        logging = "club.threecard.gamelib.logging",
        timer = "club.threecard.gamelib.timer",
        ui = "club.threecard.gamelib.ui",
        config = "club.threecard.gamelib.config",
        store = "club.threecard.gamelib.store",
        require = "club.threecard.gamelib.require",
        game_scene = "club.threecard.gamelib.game_scene",
        util = "club.threecard.gamelib.util",
        ads = "module.ads",
        utility = "module.utility",
        toast = "module.toast",
        msgbox = "module.msgbox",
        roomcache = "module.roomcache",
        entitas = "club.threecard.gamelib.entitas-lua.entitas",
        reconnection = "club.threecard.gamelib.reconnection",
        chat = "club.threecard.gamelib.chat"
    },
    start = function()
        error("游戏动态库无法直接启动")
    end,
    exit = function(self, instant)
        log.debug("开始释放")
        blaze.app.exit(self, true)

        for key, _ in pairs(package.loaded) do
            if string.find(key, "club.threecard.") ~= nil then
                package.loaded[key] = nil
            end
        end
        log.debug("释放成功")
        return blaze.promise.resolve()
    end,
    on_exited = function()
        -- 覆盖Application.Quit
    end
})

return gamelib